import { number } from 'echarts'
import request from './request'

/**
 * 登录以后返回token
 */
export const APIAdminLogin = (params: IAdminLoginParams): RES<IAdminLoginModel> => request.post('/admin/login', params)
/**
 * 获取当前登录用户信息
 */
export const APIAdminInfo = (): RES<IAdminInfoModel> => request.get('/admin/info')
/**
 * 根据用户名或姓名分页获取用户列表
 */
export const APIAdminList = (params: IAdminListParams): RES<IAdminListModel> => request.get('/admin/list', { params })
/**
 * 修改帐号状态
 */
export const APIAdminUpdateStatus = (id: number, status: number): RES<number> => request.post(`/admin/updateStatus/${id}?status=${status}`)
/**
 * 用户注册
 */
export const APIAdminRegister = (params: IAdminRegisterParams): RES<IAdminRegisterModel> => request.post('/admin/register', params)
/**
 * 获取指定用户的角色
 */
export const APIAdminRole = (adminId: number): RES<IAdminRoleModel[]> => request.get(`/admin/role/${adminId}`)
/**
 * 根据id 获取指定用户信息
 */
export const APIGetAdminInfoById = (id: number): RES<IAdminList> => request.get(`/admin/${id}`)
/**
 * 根据id 修改指定用户信息
 */
export const APIAdminUpdateById = (params: IAdminRegisterParams): RES<number> => request.post(`/admin/update/${params.id}`, params)
/**
 * 给用户分配角色
 */
export const APIAdminRoleUpdate = (adminId: number, roleIds: string): RES<number> => request.post('/admin/role/update', undefined, { params: { adminId, roleIds } })
